package it.eng.ws.test.automata;

import it.eng.ws.test.configuration.ConfigurationManager;
import it.eng.ws.test.exceptions.UAConfigurationException;
import it.eng.ws.test.exceptions.UAExecutionException;
import it.eng.ws.test.logging.LoggingSample;

import java.util.HashMap;

import org.apache.log4j.Logger;

public abstract class StateAction {

	private HashMap<String, String> params;
	protected static Logger l = null;
	
	
	public StateAction(){
		params = new HashMap<String, String>();
		if (l == null)
			l = LoggingSample.getLogger(it.eng.ws.test.automata.StateAction.class);
	}
	
	public void addParam(String key, String value){
		params.put(key, value);
	}
	
	public void getParam(String key){
		params.get(key);
	}
	
	public HashMap<String, Object> getSharedMemory() throws UAExecutionException{
		try {
			return ConfigurationManager.getInstance().getSharedMemory();
		} catch (UAConfigurationException e) {
			l.error(e.getMessage(),e);
			throw new UAExecutionException("Unexpected configuration error", e);
		}
	}
	
	public abstract void doAction() throws UAExecutionException;

}
